	package com.hochschild.sgv.util;

	import java.util.Properties;
	import javax.mail.*;
	import javax.mail.internet.*;

	public class EnviarEmail{
    
	public EnviarEmail(){}

	public String EnviarEmail(String from,
                                  String alias_from,
                                  String to,
                                  String asunto,
                                  String texto) throws Exception {
		
            try{
                Properties props = System.getProperties();
                props.put("mail.smtp.host", from);
                
                Session session = Session.getDefaultInstance(props, null);
                
                MimeMessage message = new MimeMessage(session);
                message.setFrom(new InternetAddress(alias_from));
                message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
                message.setSubject(asunto);
                
                message.setText(texto, "ISO-8859-1","html");
                //message.setContent(texto,"text/html");
                Transport.send(message);
                return "1";
            }catch(Exception e){
                System.out.println("ERROR AL ENVIAR CORREO "+e.getMessage());                
                return "Error - No se pudo enviarCorreo : "+e.getMessage();
            }
	}

}
